package com.supor.aiot.common.ui.activity;

import android.content.Intent;

import com.supor.aiot.common.R;
import com.supor.aiot.common.base.BaseMVVMActivity;
import com.supor.aiot.common.base.NoViewModel;
import com.supor.aiot.common.databinding.ActivityNfcCheckBinding;
import com.supor.aiot.common.utils.NFCCheckUtils;


public class NFCCheckActivity extends BaseMVVMActivity<NoViewModel, ActivityNfcCheckBinding> {

    @Override
    protected int resourceId() {
        return R.layout.activity_nfc_check;
    }

    @Override
    protected void initView() {
        super.initView();
        Intent intent = getIntent();
        if (null != intent) {
            int status = intent.getIntExtra(NFCCheckUtils.STATUS, NFCCheckUtils.STATUS_NO_EXIT);
            int imgResId = R.mipmap.ic_device_illegal;
            int titleResId = R.string.check_illegal;
            String tip;

            switch (status) {
                case NFCCheckUtils.STATUS_ILLEGAL:
                    tip = getString(R.string.device_illegal);
                    break;

                case NFCCheckUtils.STATUS_ILLEGAL_MEDIA:
                    tip = String.format(getString(R.string.device_illegal_check), "美的");
                    break;

                case NFCCheckUtils.STATUS_ILLEGAL_HAIER:
                    tip = String.format(getString(R.string.device_illegal_check), "海尔");
                    break;

                case NFCCheckUtils.STATUS_ILLEGAL_JOYA:
                    tip = String.format(getString(R.string.device_illegal_check), "九阳");
                    break;

                case NFCCheckUtils.STATUS_ILLEGAL_XIAOMI:
                    tip = String.format(getString(R.string.device_illegal_check), "米家");
                    break;

                default:
                    imgResId = R.mipmap.ic_device_no_exit;
                    tip = getString(R.string.device_no_exit);
                    titleResId = R.string.check_no_device;
                    break;
            }

            bindingView.ivImg.setImageResource(imgResId);
            bindingView.tvTip.setText(tip);
            bindingView.toolbar.setTitle(titleResId);
        }

        bindingView.toolbar.setIvLeftOnClickListener(v -> finish());
        bindingView.btnAck.setOnClickListener(v -> finish());
    }
}